package org.karelun.gef.property;

import org.eclipse.jface.viewers.DialogCellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FontDialog;

public class FontCellEditor extends DialogCellEditor{
	
	public FontCellEditor(Composite parent){
		this(parent,SWT.NONE);
	}
	
	public FontCellEditor(Composite parent, int style) {
		super(parent,style);
		doSetValue(new FontData("Arial",20,SWT.BOLD|SWT.ITALIC)); //$NON-NLS-1$
		
	}

	@Override
	protected Object openDialogBox(Control cellEditorWindow) {
		FontDialog dialog = new FontDialog(cellEditorWindow.getShell());
		Object value = getValue();
		if(value!=null){
			dialog.setFontList(new FontData[]{(FontData)value});
		}
		FontData fontData = dialog.open();
		return fontData;
	}

}
